$(function(){
 //第一张显示
 $(".pic li").eq(0).show();
$("#pic1").attr("class","chuxian1");
$("#pic11").attr("class","chuxian11");
 //鼠标滑过手动切换，淡入淡出
	 $("#position li").click(function() {
		 $(this).addClass('cur').siblings().removeClass("cur");
		 var index = $(this).index();
		 i = index;//不加这句有个bug，鼠标移出小圆点后，自动轮播不是小圆点的后一个
		 // $(".pic li").eq(index).show().siblings().hide();
		 $(".pic li").eq(index).fadeIn(500).siblings().fadeOut(500);
		 if(i==0){
		 	$("#pic3").attr("class","yincang3");
		 	$("#pic31").attr("class","yincang31");
		 	$("#pic32").attr("class","yincang32");
		 	$("#pic33").attr("class","yincang33");
		 	$("#pic34").attr("class","yincang34");
		 	$("#pic1").attr("class","chuxian1");
		 	$("#pic11").attr("class","chuxian11");
		 }
		 else if(i==1){
		 	$("#pic1").attr("class","yncang1");
		 	$("#pic11").attr("class","yncang11");
		 	$("#pic2").attr("class","chuxian2");
		 	$("#pic21").attr("class","chuxian21");
		 	$("#pic22").attr("class","chuxian22");
		 }
		 else if(i==2){
		 	$("#pic2").attr("class","yncang2");
		 	$("#pic21").attr("class","yncang21");
		 	$("#pic22").attr("class","yincang22");
		 	$("#pic3").attr("class","chuxian3");
		 	$("#pic31").attr("class","chuxian31");
		 	$("#pic32").attr("class","chuxian32");
		 	$("#pic33").attr("class","chuxian33");
		 	$("#pic34").attr("class","chuxian34");
		 }
	 });
	 var i=0;
 //向右切换
 var play=function(){
		 i++;
		 i = i > 2 ? 0 : i ;
		 $("#position li").eq(i).addClass('cur').siblings().removeClass("cur");
		 $(".pic li").eq(i).fadeIn(500).siblings().fadeOut(500);
		if(i==0){
		 	$("#pic3").attr("class","yincang3");
		 	$("#pic31").attr("class","yincang31");
		 	$("#pic32").attr("class","yincang32");
		 	$("#pic33").attr("class","yincang33");
		 	$("#pic34").attr("class","yincang34");
		 	$("#pic1").attr("class","chuxian1");
		 	$("#pic11").attr("class","chuxian11");
		 }
		 else if(i==1){
		 	$("#pic1").attr("class","yncang1");
		 	$("#pic11").attr("class","yncang11");
		 	$("#pic2").attr("class","chuxian2");
		 	$("#pic21").attr("class","chuxian21");
		 	$("#pic22").attr("class","chuxian22");
		 }
		 else if(i==2){
		 	$("#pic2").attr("class","yncang2");
		 	$("#pic21").attr("class","yncang21");
		 	$("#pic22").attr("class","yincang22");
		 	$("#pic3").attr("class","chuxian3");
		 	$("#pic31").attr("class","chuxian31");
		 	$("#pic32").attr("class","chuxian32");
		 	$("#pic33").attr("class","chuxian33");
		 	$("#pic34").attr("class","chuxian34");
		 }
	 }
 //向左切换
	 var playLeft=function(){
		 i--;
		 i = i < 0 ? 2 : i ;
		 $("#position li").eq(i).addClass('cur').siblings().removeClass("cur");
		 $(".pic li").eq(i).fadeIn(500).siblings().fadeOut(500);
		if(i==0){
		 	$("#pic3").attr("class","yincang3");
		 	$("#pic31").attr("class","yincang31");
		 	$("#pic32").attr("class","yincang32");
		 	$("#pic33").attr("class","yincang33");
		 	$("#pic34").attr("class","yincang34");
		 	$("#pic1").attr("class","chuxian1");
		 	$("#pic11").attr("class","chuxian11");
		 }
		 else if(i==1){
		 	$("#pic1").attr("class","yncang1");
		 	$("#pic11").attr("class","yncang11");
		 	$("#pic2").attr("class","chuxian2");
		 	$("#pic21").attr("class","chuxian21");
		 	$("#pic22").attr("class","chuxian22");
		 }
		 else if(i==2){
		 	$("#pic2").attr("class","yncang2");
		 	$("#pic21").attr("class","yncang21");
		 	$("#pic22").attr("class","yincang22");
		 	$("#pic3").attr("class","chuxian3");
		 	$("#pic31").attr("class","chuxian31");
		 	$("#pic32").attr("class","chuxian32");
		 	$("#pic33").attr("class","chuxian33");
		 	$("#pic34").attr("class","chuxian34");
		 }
	 }
 //鼠标移入移出效果
	 $("#container").hover(function() {
		 clearInterval(timer);
		 }, function() {
		 timer=setInterval(play,4000);
	 });
 //左右点击切换
	 $("#prev").click(function(){
		 playLeft();
	 })
	 $("#next").click(function(){
		 play();
	 })
 //自动轮播
	 var timer=setInterval(play,4000);
 })